package com.scfire.error

class ErrorsController {
	
	def deviceInfoService
	
	/**
	 * 页面找不到错误
	 * @param null
	 * @return null
	 *
	 * **/
	def notFound() {
		def userAgent = request.getHeader("User-Agent")
		String device = deviceInfoService.getDeviceInfo(userAgent)
		withFormat {
			html {
				if("pc".equals(device)){
					render view:"notFound.gsp"
				}else if("mobile".equals(device)){
					render view:"notFound.gsp"
				}
			}
			json {
				
			}
		}
	}
	
	/**
	 * 服务器内部错误
	 * @param null
	 * @return null
	 *
	 * **/
	def serverError() {
		def userAgent = request.getHeader("User-Agent")
		String device = deviceInfoService.getDeviceInfo(userAgent)
		withFormat {
			html {
				if("pc".equals(device)){
					render view:"serverError.gsp"
				}else if("mobile".equals(device)){
					render view:"serverError.gsp"
				}
			}
			json {
				
			}
		}
	}
	
	/**
	 * 时间错误
	 * @param null
	 * @return null
	 *
	 * **/
	def dateError() {
		def userAgent = request.getHeader("User-Agent")
		String device = deviceInfoService.getDeviceInfo(userAgent)
		withFormat {
			html {
				if("pc".equals(device)){
					render view:"dateError.gsp"
				}else if("mobile".equals(device)){
					render view:"dateError.gsp"
				}
			}
			json {
				
			}
		}
	}
	
	/**
	 * 禁止访问
	 * @param null
	 * @return null
	 *
	 * **/
	def requestForbidden() {
		def userAgent = request.getHeader("User-Agent")
		String device = deviceInfoService.getDeviceInfo(userAgent)
		withFormat {
			html {
				if("pc".equals(device)){
					render view:"requestForbidden.gsp"
				}else if("mobile".equals(device)){
					render view:"requestForbidden.gsp"
				}
			}
			json {
				
			}
		}
	}
	
}
